package com.bluedot.ssh.dao;

import java.io.Serializable;

import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;



public interface Dao<T, PK extends Serializable> {
	/**
	 * 创建对象.
	 * 
	 * @param entity
	 *            the entity
	 */
	@Transactional(propagation = Propagation.REQUIRED)
	public void create(T entity);

	/**
	 * 创建或更新对象
	 * 
	 * @param entity
	 */
	@Transactional(propagation = Propagation.REQUIRED)
	public void saveOrUpdate(T entity);

	/**
	 * 更新对象
	 * 
	 * @param entity
	 */
	@Transactional(propagation = Propagation.REQUIRED)
	public void update(T entity);

	/**
	 * 通过id得到对象
	 * 
	 * @param id
	 * @return
	 */
	@Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
	public T findById(PK id);

	/**
	 * 删除对象
	 * 
	 * @param entity
	 */
	@Transactional(propagation = Propagation.REQUIRED)
	public void delete(T entity);

	/**
	 * 分页浏览
	 * 
	 * @param pagination
	 */
	@Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
	public void findByCriteria(Pagination<T> pagination);

	/**
	 * 根据条件查询
	 * 
	 * @param condition
	 * @return
	 */
	@Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
	public Object findByCriteria(Object condition);
}
